package com.alpaak.test;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author alpaak
 * @des: TODO
 * @date 2020/4/18 14:20
 */
@Component
public class B implements ApplicationContextAware, InitializingBean {
	@Autowired
	private ApplicationContext applicationContext;

	@Autowired
	private A a;

	public B() {
		System.out.println("B constructor create .......... ");
	}

	@PostConstruct
	public void initMethod() {
		System.out.println("life circle callback ========");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
		System.out.println("call applicationContext ========");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("InitializingBean  circle callback =====");
	}
}
